﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.BLL;
using Com.CMS263.PO;
using Com.CMS263.Util;

namespace Com.CMS263.Web.manage.ProductManage
{
    public partial class product_list : System.Web.UI.Page
    {
        //searchkey start
        public int typeid = 0;
        public string styleid = "";
        //searchkey end
        public IList<Product> prodlist = new List<Product>();
        ProductBLL pbll = new ProductBLL();
        public int page = 0;
        public int pagecount = 0;
        public int pagesize = 10;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                typeid = Convert.ToInt32(Request["typeid"]);
                styleid = Request["styleid"];
                if (styleid == null)
                {
                    styleid = string.Empty;
                }
                page = Convert.ToInt32(Request["page"]);
                if (page == 0)
                {
                    page = 1;
                }
                prodlist = pbll.GetListByPager(typeid, -1, styleid, page, pagesize);
            }
        }
        public string GetTypeName(object obj)
        {
            int type = Convert.ToInt32(obj);
            switch (type)
            {
                case 1:
                    return "婚纱";
                case 2:
                    return "喜酒";
                case 3:
                    return "喜帖";
                case 4:
                    return "珠宝";
                case 5:
                    return "礼品";
                default:
                    return "婚纱";
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            typeid = Convert.ToInt32(Request["txtSearchType"]);
            styleid = Request["txtSearchStyle"];
            if (styleid == null)
            {
                styleid = string.Empty;
            }
            Response.Redirect("product_list.aspx?typeid=" + typeid + "&styleid=" + styleid);
        }
        public string GetPager()
        {
            pagecount = pbll.GetListByPager(typeid, -1, styleid);
            return EnPager.GetPager(pagecount, pagesize, page, "&typeid=" + typeid + "&styleid=" + styleid);
        }
    }
}
